package com.tjetc.output;

import org.junit.jupiter.api.Test;

import java.io.*;

public class _3BufferedWriter {

    @Test
    public void testBufferedWriter() throws IOException {
        BufferedWriter bufferedWriter =
                new BufferedWriter(new FileWriter("/Users/gaoyongxiang/百度网盘/IDEA-Java/202507-java-se/chapter16/file/hello.txt"));
        bufferedWriter.write(100);
        bufferedWriter.newLine();
//        bufferedWriter.write("\n");
        bufferedWriter.write(100);
        bufferedWriter.close();
    }


    @Test
    public void testCopyFile() throws IOException {
        try (
                BufferedReader reader =
                        new BufferedReader(new FileReader("/Users/gaoyongxiang/百度网盘/IDEA-Java/202507-java-se/chapter16/file/hello.txt"));
                BufferedWriter writer = new BufferedWriter(new FileWriter("/Users/gaoyongxiang/百度网盘/IDEA-Java/202507-java-se/chapter16/file/hello1.txt"));

        ){
            String line = "";
            while ((line = reader.readLine()) != null) {
                writer.write(line);
                writer.newLine();
            }
        }
    }
}
